////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// The MIT License (MIT)                                                      //
//                                                                            //
// Copyright (c) 2013 Charles Teague                                          //
//                                                                            //
// Permission is hereby granted, free of charge, to any person obtaining a    //
// copy of this software and associated documentation files (the "Software"), //
// to deal in the Software without restriction, including without limitation  //
// the rights to use, copy, modify, merge, publish, distribute, sublicense,   //
// and/or sell copies of the Software, and to permit persons to whom the      //
// Software is furnished to do so, subject to the following conditions:       //
//                                                                            //
// The above copyright notice and this permission notice shall be included in //
// all copies or substantial portions of the Software.                        //
//                                                                            //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   //
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    //
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    //
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        //
// DEALINGS IN THE SOFTWARE.                                                  //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using RPSDAL.EntityClasses;


/// <summary>
/// Summary description for MailManager
/// </summary>
public class MailManager
{
    public MailManager()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    
    public static void SendPaswordRecovery(UserEntity user)
    {
        MailerConfigurator config = new MailerConfigurator(true);
        /*bool test = System.IO.File.Exists("http://localhost:1855/RPS/App_Data/MailTemplates/ForgotLoginTemplate.xml");
        config.AddProperty(MailerConfigurator.BaseTemplatePath, "http://localhost:1855/RPS/App_Data/MailTemplates/MailBaseMailTemplate.xml");
        config.AddProperty(MailerConfigurator.TemplatePath, "http://localhost:1855/RPS/App_Data/MailTemplates/ForgotLoginTemplate.xml");
        config.AddProperty(MailerConfigurator.MailTo, user.Email);
         */
        bool test = System.IO.File.Exists(LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.BaseTemplatePath, LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.TemplatePath, LoginPageMapper.MailForgotPasswordTemplate);
        config.AddProperty(MailerConfigurator.MailTo, user.Email);
        //decrypt password
        //decrypt password
      //  user.Password = Global.DecryptString(user.Password);
        
        config.AddObject("User", user);
        
        
        new Mailer(config).SendMail();

    }
   /* public static void SendLoginRecovery(UserEntity user)
    {
        MailerConfigurator config = new MailerConfigurator(true);
        bool test = System.IO.File.Exists(LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.BaseTemplatePath, LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.TemplatePath, LoginPageMapper.MailForgotLoginTemplate);
        config.AddProperty(MailerConfigurator.MailTo, user.Email);
        //decrypt password
        user.Password = Global.DecryptString(user.Password);
        config.AddObject("User", user);
        
       

        new Mailer(config).SendMail();

    }
    public static void SendMailSupport(MailSupport support)
    {
        MailerConfigurator config = new MailerConfigurator(true);
        bool test = System.IO.File.Exists(LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.BaseTemplatePath, LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.TemplatePath, LoginPageMapper.MailSupportTemplate);
        config.AddProperty(MailerConfigurator.MailFrom, support.Email);
        config.AddProperty(MailerConfigurator.MailTo, ConfigurationManager.AppSettings["EmailSupport"]);

        config.AddObject("Support", support);
        if (support.FileUploadSupport != "")
        {
            System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(support.FileUploadSupport);
            new Mailer(config).SendMailWithAttachment(attach);
        }
        else
            new Mailer(config).SendMail();

    }
    /*public static void SendMailContactUs(MailContactUs contact)
    {
        MailerConfigurator config = new MailerConfigurator(true);
        bool test = System.IO.File.Exists(LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.BaseTemplatePath, LoginPageMapper.MailBaseMailTemplate);
        config.AddProperty(MailerConfigurator.TemplatePath, LoginPageMapper.MailContactUsTemplate);
        config.AddProperty(MailerConfigurator.MailFrom, contact.Email);
        config.AddProperty(MailerConfigurator.MailTo, ConfigurationManager.AppSettings["EmailSupport"]);

        config.AddObject("Contact", contact);
        new Mailer(config).SendMail();


    }*/
}
